<template>
    <div id="member">
        <el-table
        :data="tableData"
        style="width: 100%">
        <el-table-column
            prop="rank"
            width="60"
            label="排名">
        </el-table-column>
        <el-table-column
            prop="date"
            label="头像"
            width="100">
            <template slot-scope="scope">
                <div>
                    <img :src="scope.row.photo_url" alt="" style="width:60px;border-radius:50%;height:60px;object-fit:cover">
                </div>
            </template>
        </el-table-column>
        <el-table-column
            prop="name"
            label="姓名/昵称"
            width="180">
            <template slot-scope="scope">
                <div>{{scope.row.realname?scope.row.realname:scope.row.nickname}}</div>
            </template>
        </el-table-column>
        <el-table-column
            prop="phone"
            width="180"
            label="手机号">
        </el-table-column>
        <el-table-column
            prop="one_score"
            width="180"
            label="一轮成绩">
        </el-table-column>
        <el-table-column
            prop="two_score"
            width="180"
            label="二轮成绩">
        </el-table-column>
        <el-table-column
            prop="address"
            label="操作"
            min-width="200"
            >
            <template slot-scope="scope">
                <div>
                   <el-button type="primary" @click="showScore(scope.row.id)">查看答卷</el-button>
                </div>
            </template>
        </el-table-column>
        </el-table>
        <el-col :span="24" class="footer-bar">
			<div class="page-code">
				<el-pagination
					background
					:page-size="30"
					layout="prev, pager, next"
					:total="totalPage"
					@current-change="pageChange"
						>
				</el-pagination>
			</div>
    </el-col>

    <el-dialog title="评分" :visible.sync="scroeVisible" @close="initData">
            <el-form label-position="top" label-width="400px"  v-for="(item,index) of questionAnswerList" :key="index">
                <el-form-item :label="item.questions">
                    <div>{{item.user_answer}}</div>
                </el-form-item>
            </el-form>
			<div slot="footer" class="dialog-footer">
				<el-button type="primary" @click="scroeVisible=false">关闭</el-button>
			</div>
		</el-dialog>
    </div>
</template>
<script>
export default {
    name:'member',
    data() {
        return {
            questionSheetId:'',//选中的答卷
            scroeVisible:false,
            tableData: [],
            page:1,
            totalPage:0,
            questionAnswerList:''    
        }
    },
    methods: {
        async getLeaderBoard(){
            //获取会员列表
            let params={
                page:this.page,
                limit:30
            }
            let res=await this.$api.getLeaderBoard(
                params);
            if(res.data.level=='success'){
                this.tableData=res.data.data;
                this.totalPage=res.data.page_info.total
            }
        },
        showScore(id){
            this.questionSheetId=id;
            this.scroeVisible=true;
            this.getUserQuestionAnswer()
        },
        async getUserQuestionAnswer(){
            //获取答题详情
            let params={
                id:this.questionSheetId
            }
            let res=await this.$api.getUserQuestionAnswer(params);
            if(res.data.level=='success'){
                this.questionAnswerList=res.data.data
            }
        },
        pageChange(e){
			//翻页
			this.page=e;
			this.getLeaderBoard();
        },
        initData(){
            this.questionAnswerList='';
            this.questionSheetId='';
        },
    },
    mounted() {
        this.getLeaderBoard()
    },
}
</script>
<style lang="scss" scoped>
    .action-bar{
			background-color: #f2f2f2;
			height: 60px;
			margin: 10px 0px;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			padding-left: 20px;
			.action-bar-input{
				width: 250px;
				margin-right: 14px;
      }
      .task-form-text{
				color: #666666;
			}
		}
		.el-table-style{
			width: 100%;
			border: 1px solid #f2f2f2;
		}
		.footer-bar{
			display: flex;
			justify-content: space-between;
			align-items: center;
			background: #f2f2f2;
			padding: 8px;
			margin: 10px 0px;
			box-sizing: border-box;
		}
		.dialog-footer{
			text-align: center;
		}
		.executorList{
			display: flex;
			flex-wrap: wrap;
			div{
				margin:10px;
				border:1px solid #eee;
				border-radius: 5px;
				padding:5px 10px;
			}
		}
</style>